//===- AADriver.cpp - Driver for Alias Analysis" --------------------------===//
//
//	Copyright (C) 2014	Victor Hugo Sperle Campos
//						George Souza Oliveira
//				
//
//===----------------------------------------------------------------------===//

#define DEBUG_TYPE "AADriver"

#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
#include "llvm/Pass.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"


namespace llvm {

// This is a very naive implementation of disjoint sets,
// for the purpose of simplicity.
typedef struct {
	SmallVector<SetVector<Value*>, 16> sets;
	
	void make_set(Value* p);
	int find_set(Value* p);
	void union_sets(unsigned i, unsigned j);
} DisjointSets;


// AADriver
struct AADriver : public ModulePass {
	static char ID; // Pass identification, replacement for typeid
	AADriver() : ModulePass(ID) {
	}

	virtual bool runOnModule(Module &M);

	// We don't modify the program, so we preserve all analyses
	virtual void getAnalysisUsage(AnalysisUsage &AU) const;
	
	DisjointSets* DS;	
	
};

static inline bool isInterestingPointer(Value *V) {
  return V->getType()->isPointerTy()
      && !isa<ConstantPointerNull>(V);
}

}
